package com.killer.controller;

import com.killer.pojo.Seckill;
import com.killer.service.SeckillService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author ：Killer
 * @date ：Created in 21-3-24 上午10:08
 * @description：${description}
 * @modified By：
 * @version: version
 */
@RestController
@RequestMapping("seckill")
public class SeckillController {

    @Autowired
    private SeckillService seckillService;

    @RequestMapping(value = "/add",method = RequestMethod.POST)
    public Object addSeckill(@RequestParam Long productId,@RequestParam Integer count){
        Seckill seckill = seckillService.addSeckill(productId, count);
        return seckill;
    }

    @RequestMapping(value = "/do",method = RequestMethod.POST)
    public Object doSeckill(@RequestParam Long id) {
        seckillService.doSeckill(id);
        return "秒杀成功,请在订单生成后的30秒内支付订单";
    }
}
